package com.fanbuchi.fukua.net;

import com.fanbuchi.fukua.application.SuperApp;
import com.fanbuchi.fukua.entity.OauthEntity;

import java.io.IOException;

/**
 * Created by Administrator on 2015/7/10.
 */
public abstract class BaseCallBack<T> extends StringsCallBack  {

    T t;
    Class<T> p;
     private BaseCallBack(){

     }

    protected BaseCallBack(Class<T> p){
        this.p=p;
    }


    @Override
    public void onResponseOk(String body) {
        try {
        System.out.println(body);
          //  OauthEntity oauthEntity=SuperApp.getMapper().readValue(body, OauthEntity.class);
           t=(T)SuperApp.getMapper().readValue(body,p);
            onResponseOk(t);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public abstract void onResponseOk(T body);

}
